package com.yanlin.servicedriveruser.controller;


import com.yanlin.internalcommon.dto.Car;
import com.yanlin.internalcommon.dto.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.yanlin.serviceDriverUser.service.ICarService;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yanlin
 * @since 2025-06-13
 */
@RestController
public class CarController {

    @Autowired
    private ICarService carService;

    @PostMapping("/car")
    public ResponseResult addCar(@RequestBody Car car) {
        return carService.addCar(car);
    }

    @GetMapping("/car/{state}")
    public ResponseResult getCar(@PathVariable Integer state) {
        System.out.println("state = " + state);
        ResponseResult result = carService.getCar(state);
        return result;
    }

    @GetMapping("/test")
    public ResponseResult test() {
        return ResponseResult.success("test service driver user");
    }
}
